#ifndef FILE_H
#define FILE_H

#include "types.h"

#define FILE_TABLE_SIZE   2048
#define FILE_NAME_SIZE    32

typedef enum _file_type_t{
    FILE_UNKNOWN = 0,
    FILE_TTY =1,
    FILE_NORMAL,
    FILE_DIR,
}file_type_t;

struct _fs_t;

typedef struct _file_t{
    char file_name[FILE_NAME_SIZE];
    file_type_t type;
    uint32_t size;
    int ref;//open_count
    int dev_id;
    int pos;//read position
    int sblk; //cluster idex
    int cblk; //current cluster
    int p_index; //file index in fat,can be used for create new file
    int mode;//O_RDONLY,O_WRONLY
    struct _fs_t *fs;
}file_t;

file_t * file_alloc(void);
void file_free(file_t * file);
void file_table_init(void);
void file_inc_ref(file_t * file);

#endif